package entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table (name= "remitos")
public class RemitoEntity implements Serializable {
	
	@Transient
	private static final long serialVersionUID = 1L;
	
		@Id @GeneratedValue
		private Integer nroRemito;
		@Column (name= "fechaEmision")
		private Date fechaEmision = null;
		@OneToMany (cascade = CascadeType.ALL)
		@JoinColumn (name= "nroRemito")
		private List<ItemRemitoEntity> items = new ArrayList<ItemRemitoEntity>();

		
		
		public RemitoEntity() {
		}

		
		
		public Integer getNroRemito() {
			return nroRemito;
		}
		public void setNroRemito(Integer nroRemito) {
			this.nroRemito = nroRemito;
		}
		public Date getFechaEmision() {
			return fechaEmision;
		}
		public void setFechaEmision(Date date) {
			this.fechaEmision = date;
		}
		public List<ItemRemitoEntity> getItems() {
			return items;
		}
		public void setItems(List<ItemRemitoEntity> items) {
			this.items = items;
		}



		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result
					+ ((fechaEmision == null) ? 0 : fechaEmision.hashCode());
			result = prime * result + ((items == null) ? 0 : items.hashCode());
			result = prime * result
					+ ((nroRemito == null) ? 0 : nroRemito.hashCode());
			return result;
		}



		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			RemitoEntity other = (RemitoEntity) obj;
			if (fechaEmision == null) {
				if (other.fechaEmision != null)
					return false;
			} else if (!fechaEmision.equals(other.fechaEmision))
				return false;
			if (items == null) {
				if (other.items != null)
					return false;
			} else if (!items.equals(other.items))
				return false;
			if (nroRemito == null) {
				if (other.nroRemito != null)
					return false;
			} else if (!nroRemito.equals(other.nroRemito))
				return false;
			return true;
		}

		
		
}
